<script setup lang="ts">
defineOptions({ name: 'ProOptionItem' })

const props = withDefaults(defineProps<Props>(), {
  icon: '',
  label: '',
  more: false,
  active: false,
})

const emit = defineEmits<{
  (e: 'click'): void
}>()

interface Props {
  icon?: string
  label?: string
  more?: boolean
  active?: boolean
}

const handleClick = () => {
  emit('click')
}
</script>

<template>
  <li
    class="pro-option-item"
    :class="{ 'pro-option-item--more': props.more, 'pro-option-item--active': props.active }"
    @click="handleClick"
  >
    <div class="pro-option-item__wrapper">
      <span class="pro-option-item__icon">
        <slot v-if="props.icon" name="icon">
          <ProIcon :icon="props.icon" />
        </slot>
      </span>
      <slot>
        <span class="pro-option-item__label">{{ props.label }}</span>
      </slot>
    </div>
    <IconRight v-if="props.more" />
  </li>
</template>

<style lang="less" scoped>
.pro-option-item {
  padding: 0 5px 0 10px;
  height: 34px;
  line-height: 34px;
  user-select: none;
  position: relative;
  display: flex;
  align-items: center;
  color: var(--color-text-2);
  font-size: 14px;
  cursor: pointer;
  &__wrapper {
    display: flex;
    align-items: center;
  }
  &__icon {
    margin-right: 8px;
    display: flex;
    align-items: center;
  }
  &--active,
  &:hover {
    color: rgb(var(--primary-6));
    background: var(--color-primary-light-1);
  }
  &--more {
    justify-content: space-between;
  }
}
</style>
